<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <title>交易金额</title>
</head>

<body>
<div class="layui-fluid">
    <div style="height:11px;"></div>
    <blockquote class="layui-elem-quote">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">订单状态</label>
                <div class="layui-input-inline">
                    <select name="state" id="state">
                        <option value="">==全部类别==</option>
                        <option value="0" {if isset($getdata['state']) && $getdata['state']=='0'}selected{/if}>--未支付--</option>
                        <option value="1" {if isset($getdata['state']) && $getdata['state']=='1'}selected{/if}>--支付成功--</option>
                        <option value="2" {if isset($getdata['state']) && $getdata['state']=='2'}selected{/if}>--支付失败--</option>
                        <option value="3" {if isset($getdata['state']) && $getdata['state']=='3'}selected{/if}>--处理中--</option>
                        <option value="4" {if isset($getdata['state']) && $getdata['state']=='4'}selected{/if}>--已退款--</option>
                        <option value="5" {if isset($getdata['state']) && $getdata['state']=='5'}selected{/if}>--免费升级--</option>
                        <option value="6" {if isset($getdata['state']) && $getdata['state']=='6'}selected{/if}>--关系升级--</option>
                    </select>
                </div>
                <label class="layui-form-label">订单状态</label>
                <div class="layui-input-inline">
                    <select name="type_id" id="type_id">
                        <option value="">==全部类别==</option>
                        {volist name='typeList' id='lt'}
                        <option value="{$lt.type_id}" {if isset($getdata['type_id']) && $getdata['type_id']==$lt['type_id']}selected{/if}>{$lt.type_name}</option>
                        {/volist}
                    </select>
                </div>
                <label class="layui-form-label">时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="query_date" id="query_date" autocomplete="off" class="layui-input" readonly="readonly">
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit lay-filter="sub">查询</button>
                </div>
            </div>
        </div>
    </blockquote>

    <blockquote class="layui-elem-quote">
        以下所有数据在没有选择日期范围的时候就是总数据，如果选择日期范围那么就是日期范围内的总数据<br>
        成交总额：<span id="total">0</span>元 <br>
        成交纯利润：<span id="profit_total">0</span>元<br>
    </blockquote>

    <div class="layui-btn-group" id="toolbar" style="display: none;">
        <!-- <button class="layui-btn" id="add" onclick="openWin('新增内容','{:url('add')}');"><i class="layui-icon">&#xe654;</i>增加</button>
        <button class="layui-btn" id="edit" onclick="openEditWin('{:url('edit')}','id');"><i class="layui-icon">&#xe642;</i>编辑</button> -->
        <button class="layui-btn" id="del" onclick="delItem('{:url('dels')}', 'id');"><i class="layui-icon">&#xe640;</i>批量删除
        </button>
    </div>

    <div id="table" lay-filter="table" class="layui-table"></div>


    <!-- tpl区域 -->
    <script type="text/html" id="bar">
<!--        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script type="text/html" id="ShowImg">
        <a class="layui-btn layui-btn-xs" lay-event="edit" href="{{ d.logo }}" target="_blank">点击查看图片</a>
    </script>

    <script type="text/html" id="status_text">
        {{# if(d.status == '上架'){ }}
        <button class="layui-btn layui-btn-xs">上架中</button>
        {{# }else if(d.status == '下架'){ }}
        <button class="layui-btn layui-btn-xs layui-btn-danger">已下架</button>
        {{# } }}
    </script>


</div>
<link href="__PLUS__/layui/css/layui.css" rel="stylesheet"/>
<script src="__PLUS__/layui/layui.js"></script>
<script>
    layui.use(["jquery", "form", "layer", "table", "laydate"], function () {
        var $ = layui.jquery, layer = layui.layer, table = layui.table, form = layui.form,laydate=layui.laydate;

        laydate.render({
            elem:"#query_date",
            range:true
        });


        var options = {
            elem: '#table',
            url: "{:url('index')}", //数据接口
            cols: [[ //表头
                {type: "checkbox"},
                {field: 'upgrade_uid', title: '用户手机号'},
                {field: 'upgrade_form_no', title: '订单号'},
                {field: 'upgrade_sn', title: '上游订单号'},
                {field: 'upgrade_money', title: '金额'},
                {field: 'upgrade_type_id', title: '升级类别'},
                {field: 'upgrade_state', title: '支付状态'},
                {field: 'upgrade_time', title: '发起时间'},
                {field: 'upgrade_oktime', title: '完成时间'},
                {title: '操作', toolbar: "#bar"},
            ]],
            page: true, //开启分页
            loading: true,
            limit: 20,
            done:function(res, curr, count){
                //console.log(res);
                $("#total").text(res.total_money);
                $("#profit_total").text(res.profit_money);
            }
        };
        var tableIns = table.render(options);

        //搜索提交
        form.on("submit(sub)", function (res) {
            var data = res.field;
            //console.log(data);
            options["where"] = data;
            tableIns.reload(options);
            return false;
        });


        table.on('tool(table)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            //alert(obj.event);return false;
            if (layEvent === 'edit') { //查看
                location.href = "{:url('edit')}?id=" + data.upgrade_id;
            } else if (layEvent === 'del') { //查看
                layer.confirm("确定删除吗？", function () {
                    $.post("{:url('dels')}", {ids: data.upgrade_id}, function (res) {
                        if (res.msg != '') {
                            layer.msg(res.msg);
                        }
                        if (res.url != '') {
                            window.location.href = res.url;
                        }
                    });
                });

            }
        });
    });
</script>
</body>
</html>